from itsdangerous import json


class Result:
    def __init__(self, state, msg, data):
        self.state = state
        self.msg = msg
        self.data = data

    @staticmethod
    def succ(data):
        entity = Result(200, "成功！", data)
        return json.dumps(entity.__dict__, ensure_ascii=False)

    @staticmethod
    def fail():
        entity = Result(400, "错误", None)
        return json.dumps(entity.__dict__, ensure_ascii=False)

    @staticmethod
    def fail(msg):
        entity = Result(400, msg, None)
        return json.dumps(entity.__dict__, ensure_ascii=False)
